<template>
  <div>
    <h1>页面丢失，请访问首页 -- {{ time }}</h1>
  </div>
</template>

<script>
export default {
  data() {
    return {
      time: 3
    }
  },
  mounted() {
    this.timer = setInterval(() => {
      this.time--
      console.log(11)
      if (this.time == 0) {
        // 404重定向或退出操作，一般调用location来进行跳转让浏览器刷新，为了清理一下数据
        // window.location.href = '/'
        this.$router.replace('/')
      }
    }, 1000)
  },
  beforeUnmount() {
    console.log('清理一下定时任务')
    this.timer && clearInterval(this.timer)
  }
}
</script>

<style lang="scss" scoped></style>
